<template>
  <view class="main-container">
		<!--  头部搜索栏 -->
		<view class="head">
			<view class="search_view">
				<input class="search" placeholder="请输入关键字搜索" />
			</view>
		</view>
	 
		<!--项目列表-->
		<scroll-view v-if="currentStatus == 1" class="policy_list" scroll-y="true" :style="'width:100%;height:1000rpx'" enable-flex  @scrolltolower="scrollToLower">
			<view class="policy_item"  v-for="(item, index) in techProjectList" :key="item.order_no" @click="projectDetail(techProjectList[index])">
				<view>
					<text class="policy_title">{{item.xmmc1}}</text>
				</view>
				<view>
					<text class="publicTime">{{item.createTime}}</text>
				</view>
				<view class="devideline"></view>
			</view>

		  <view class="no-data" v-if="orderList[currentStatus].length == 0">
			<image src="https://file.genepre.com/wechat/nomsg5_new.png" mode="aspectFit" class="no-data-img"></image>
			暂无数据
		  </view>
		</scroll-view>
		<!--基金列表-->
		<scroll-view v-if="currentStatus == 2" class="policy_list" scroll-y="true" :style="'width:100%;height:1000rpx'" enable-flex  @scrolltolower="scrollToLower">
			<view class="policy_item"  v-for="(item, index) in techMoneyList" :key="item.order_no" @click="moneyDetail(techMoneyList[index])">
				<view>
					<text class="policy_title">{{item.projectName}}</text>
				</view>
				<view>
					<text class="publicTime">{{item.createTime}}</text>
				</view>
				<view class="devideline"></view>
			</view>
		
		  <view class="no-data" v-if="orderList[currentStatus].length == 0">
			<image src="https://file.genepre.com/wechat/nomsg5_new.png" mode="aspectFit" class="no-data-img"></image>
			暂无数据
		  </view>
		</scroll-view>
	  </view>
</template>

<script>
	import orderTabBar from '@/wxcomponents/tab_bar.vue';
	import * as techProject from '@/api/source/project/KJJHXM.js'
	import * as techMoney from '@/api/source/project/KCJJ.js'
	export default {
	  components: {
		orderTabBar,
	  },
	  data() {
		return {
		  // 当前查询状态
		  currentStatus: 'all',
		  // 订单列表高度
		  orderHeight: 0,
		  // 是否还有更多数据
		  noMoreData: {},
		  // 订单列表
		  techProjectList: [],
		  techMoneyList:[],
		  // 页码数组
		  pageNum: 0,
		  // 每页请求数
		  pageSize: 10,
		}
	  },
	  onLoad(option){
			this.currentStatus = option.type
			if(this.currentStatus == 1){
				this.getTechProjectList()
			}else{
				this.getTechMoneyList()
			}
	  },
	  methods: {
		// 加载项目列表
		getTechProjectList() {
			uni.showLoading({});
			const query = {
				pageSize:this.pageSize,
				pageNum:this.pageNum
			}
			techProject.listKJJHXM(query).then((res)=>{
				this.techProjectList = res.rows
				uni.hideLoading({});
			})
		},
		// 加载基金列表
		getTechMoneyList() {
			uni.showLoading({});
			const query = {
				pageSize:this.pageSize,
				pageNum:this.pageNum
			}
			techMoney.listKCJJ(query).then((res)=>{
				this.techMoneyList = res.rows
				uni.hideLoading({});
			})
		},
		// 更新order
		updateOrderInfo(index) {
			if(this.currentStatus == 1){
				this.getTechProjectList()
			}else{
				this.getTechMoneyList()
			}
		},
		// 滑到底部 加载更多
		scrollToLower() {
			this.pageNum = this.pageNum + 1
			if(this.currentStatus == 1){
				this.getTechProjectList()
			}else{
				this.getTechMoneyList()
			}
		},
		// projectDetail(item){
		// 	uni.navigateTo({
		// 		url:'/subpages/pages/detail/project_detail?id='+item.id
		// 	})
		// },
		moneyDetail(item){
			uni.navigateTo({
				url:'/subpages/pages/detail/money_detail?id='+item.id
			})
		}
	  },
	  computed: {
			
	  }
	}
</script>

<style>
	
	.head {
		width: 100%;
		height:200rpx;
		background-color: #016fb8;
	}
	
	.search {
		background-color: #fff;
		width: 90%;
		margin: 35rpx auto;
		height: 60rpx;
		border-radius: 30rpx;
	}
	
	.main-container {
	  width: 100vw;
	  height: 100vh;
	  display: flex;
	  flex-direction: column;
	  justify-content: flex-start;
	  align-items: center;
	  background-color: #e6e6e6;
	}

	.main-container .tab-bar {
	  width: 100%;
	}

	.main-container .order-lists {
	  width: 100%;
	  display: flex;
	  flex-direction: column;
	  justify-content: flex-start;
	  align-items: center;
	}
	
	.no-data {
	  width: 100%;
	  height: 300rpx;
	  display: flex;
	  flex-direction: column;
	  justify-content: center;
	  align-items: center;
	  font-size: 32rpx;
	  margin-top: 100rpx;
	}
	
	.no-data .no-data-img {
	  width: 300rpx;
	  height: 268rpx;
	}
	
	.policy_list {
		width: 95%;
		margin: 20rpx auto;
		height: 660rpx;
		background-color: #fff;
	}
	
	.policy_item {
		margin-left: 20rpx;
		padding: 20rpx;
		background-color: #fff;
	}
	
	.policy_title {
		display: -webkit-box;
		width: 650rpx;
		font-size: 30rpx;
		overflow: hidden;
		white-space: nowrap;
		text-overflow:ellipsis;
		-webkit-box-orient: vertical; /*排列方式*/ 
		-webkit-line-clamp: 1; /*显示文本行数(这里控制多少行隐藏)*/
	}
	
	.publicTime {
		float:left;
		font-size: 26rpx;
		color: #a1a1a1;
		margin-top: 15rpx;
	}
	
	.devideline {
		float: left; 
		height: 0.3rpx;
		width:100%;
		background-color: #eeeeee;
		margin-top: 15rpx;
		margin-bottom: 15rpx;
	}
</style>